<template>
  <div class="drawer">
    <el-drawer :visible="drawer" :with-header="false" :size="width" @close="close">
      <div class="title">
        <div class="name">{{ title }}</div>
        <div class="closeBtn"><i class="el-icon-close" @click="close"></i></div>
      </div>
      <div class="content">
        <slot name="content"></slot>
      </div>
      <div class="footer">
        <div class="left">
          <slot name="footerLeft"></slot>
        </div>
        <div class="right">
          <slot name="footerRight"></slot>
        </div>
      </div>
    </el-drawer>
  </div>
</template>
<script>
export default {
  name: 'BaseDrawer',
  props: {
    width: { default: '600px' },
    title: { default: '标题' },
    drawer: { type: Boolean, default: true }
  },
  data() {
    return {}
  },
  methods: {
    close() {
      this.drawer ? this.$emit('close') : false
    }
  }
};
</script>
<style lang="scss" scoped>
::v-deep .el-drawer__body {
  padding: 0 !important;
}

.drawer {

  .title {
    width: 100%;
    height: 54px;
    border: 1px solid #E2E7EE;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;

    .name {
      font-size: 18px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #303133;
    }

    .closeBtn {
      cursor: pointer;
    }
  }

  .content {
    padding: 24px 24px 14px 24px;
    height: calc(100vh - 120px);
    overflow: auto;
  }

  .footer {
    height: 66px;
    border: 1px solid #E2E7EE;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
  }
}</style>
